﻿using System;
using System.Runtime.InteropServices;
using System.Threading;

namespace Victor_test1
{
    class CapsLockRinger
    {
        [DllImport("user32.dll")]
        static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);

        const byte VK_CAPITAL = 0x14;
        const uint KEYEVENTF_KEYUP = 0x0002;

        const uint KEYEVENTF_EXTENDEDKEY = 1;
        public void PressCapsLock()
        {
            keybd_event(VK_CAPITAL, 0x3A, KEYEVENTF_EXTENDEDKEY | 0, UIntPtr.Zero);
            keybd_event(VK_CAPITAL, 0x3A, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, UIntPtr.Zero);
        }

        public void Ring(int count)
        {
            // count == 5


            for (int i = 0; i < count; i++)
            {
                PressCapsLock();
                Thread.Sleep(50);
                PressCapsLock();
                Thread.Sleep(50);
            }
        }
    }
}
